package com.iot.core.config;

import com.iot.core.data.entity.HtTbid;
import com.iot.core.mybatisflex.MyLogicDeleteProcessor;
import com.iot.core.springboot.ApplicationUtils;
import com.iot.core.springboot.properties.ProjectInfoProperty;
import com.mybatisflex.core.audit.AuditManager;
import com.mybatisflex.core.logicdelete.LogicDeleteProcessor;
import com.mybatisflex.core.logicdelete.impl.DateTimeLogicDeleteProcessor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class MybatisflexConfig {

    public MybatisflexConfig() {
        var projectInfoProperty= ApplicationUtils.getBean(ProjectInfoProperty.class);
        if(projectInfoProperty.isDebugMode()){
            //开启审计功能
            AuditManager.setAuditEnable(true);

            //设置 SQL 审计收集器
            AuditManager.setMessageCollector(auditMessage ->
                    log.info(">>>>>>>>>>{}ms >>>>> {}", auditMessage.getElapsedTime() ,auditMessage.getFullSql() )
            );
        }
    }

//    @Bean
//    public LogicDeleteProcessor logicDeleteProcessor(){
//        return new MyLogicDeleteProcessor();
//    }

}
